package gui;


import java.awt.event.MouseEvent;

import javax.swing.event.MouseInputAdapter;




/**
 * 
 * @author Anton
 * Reacts to mouse events within the CenterPanel, sends them to
 * CenterPanelMapListener or CenterPanelBattleListener depending
 * on state.
 */
public class CenterPanelListener extends MouseInputAdapter {
	
	private GUICore guiCore=GUICore.getInstance();
	
	private MouseInputAdapter mapListener=new CenterPanelMapListener();
	private MouseInputAdapter battleListener=new CenterPanelBattleListener();

	private MouseInputAdapter currentListener;
	
	public CenterPanelListener(){
		updateState();
	}
	
	private void updateState(){
		switch(guiCore.currentView){
		case MAP:
			currentListener=mapListener;
			break;
		case BATTLE:
			currentListener=battleListener;
			break;
		}
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		updateState();
		currentListener.mouseClicked(e);
		
	}
	
	@Override
	public void mouseDragged(MouseEvent e){
		updateState();
		currentListener.mouseDragged(e);
	}
	
	@Override
	public void mouseMoved(MouseEvent e){
		updateState();
		currentListener.mouseMoved(e);
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		updateState();
		currentListener.mouseEntered(e);
	}

	@Override
	public void mouseExited(MouseEvent e) {
		updateState();
		currentListener.mouseExited(e);

	}

	@Override
	public void mousePressed(MouseEvent e) {
		updateState();
		currentListener.mousePressed(e);
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		updateState();
		currentListener.mouseReleased(e);

	}

}
